#!/usr/bin/python3

import asyncio, evdev

# 检测到输入时触发
async def print_events(device):
	async for event in device.async_read_loop():
		print(device.path, evdev.categorize(event), sep=': ')

devices = [evdev.InputDevice(path) for path in evdev.list_devices()]

print('发现以下设备: ')
for device in devices:
	print(device.path, device.name, device.phys)

for device in devices:
	asyncio.ensure_future(print_events(device))

loop = asyncio.get_event_loop()
loop.run_forever()
